package reduce.fz.com.reduce.fragment;


import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.adapter.BaseRecycleViewHolder;
import reduce.fz.com.reduce.bean.FindUser;
import reduce.fz.com.reduce.custom.FollowView;
import reduce.fz.com.reduce.fragment.base.BaseListFragment;

/**
 * 发现用户列表fragment,智能推荐
 */
public class FindUserFragment extends BaseListFragment<FindUserFragment.MyViewHolder, FindUser> {
    public FindUserFragment() {
    }

    @Override
    public MyViewHolder createItemViewHolder(ViewGroup parent) {
        View view = layoutInflater.inflate(R.layout.find_user_item, parent, false);
        MyViewHolder holder = new MyViewHolder(view);
        return holder;

    }

    @Override
    public MyViewHolder createfootViewHolder(View view) {
        return new MyViewHolder(view);
    }

    @Override
    public String createReqUrl() {
        return "";
    }


    public static class MyViewHolder extends BaseRecycleViewHolder<FindUser> {
        //用户头像
        private ImageView mUserHeader;
        //用户昵称
        private TextView mTvUserNickName;
        //用户签名
        private TextView mUserNote;
        //用户关注
        private FollowView mUserFollow;
        //3张用户动态图片
        private ImageView mIv1;
        private ImageView mIv2;
        private ImageView mIv3;


        public MyViewHolder(View itemView) {
            super(itemView);
        }

        public void initWidget(View view) {
            mUserHeader = (ImageView) view.findViewById(R.id.user_header);
            mTvUserNickName = (TextView) view.findViewById(R.id.tv_user_nickname);
            mUserNote = (TextView) view.findViewById(R.id.user_note);
            mUserFollow = (FollowView) view.findViewById(R.id.user_follow);
            mIv1 = (ImageView) view.findViewById(R.id.iv1);
            mIv2 = (ImageView) view.findViewById(R.id.iv2);
            mIv3 = (ImageView) view.findViewById(R.id.iv3);

        }

        @Override
        public void renderView(FindUser data, int position) {

            Picasso.with(context).load(data.user.headurl).into(mUserHeader);
            mTvUserNickName.setText(data.user.nickname);
            mUserNote.setText("");
            mUserFollow.setFollowUser(data.user.getUid());
            if (data.dynamicImages == null || data.dynamicImages.size() == 0) return;
            int size = data.dynamicImages.size();
            if (size >= 1)
                Picasso.with(context).load(data.dynamicImages.get(0)).into(mIv1);
            if (size >= 2)
                Picasso.with(context).load(data.dynamicImages.get(1)).into(mIv2);
            if (size >= 3)
                Picasso.with(context).load(data.dynamicImages.get(2)).into(mIv3);

        }
    }


}
